<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <?php $this->load->view('user/_html_head') ?>   
    <script type="text/javascript">
      var country_signup = 0,state_signup = 0;
      jQuery(document).ready(function(){
        jQuery('#signup').validationEngine();
        $('#country_signup').bind({
          change: function (){detect_country($(this).val());},
          blur: function (){detect_country($(this).val());}
        });
        $('#state_signup').bind({
          change: function (){detect_state($(this).val());},
          blur: function (){detect_state($(this).val());}
        });
        detect_country($('#country_signup').val());
      });
      function detect_country(id){
        if(country_signup != id){
          country_signup = id;
          $('#state_signup').html('');
          $('#state_signup').html('<option value=""><?php echo $this->lang->line('label.state.select') ?></option>');
          if(id){
            $.post('<?php echo site_url('admin/ajax/list_json_state') ?>', {id : id}, function(data){
              if(data){                
                $.each(data, function(key, value){
                  $('#state_signup').append('<option '+
                    (value['id'] == '<?php echo isset($obj['state_id']) ? $obj['state_id'] : 0 ?>' ? 'selected="selected"' :'' )
                    +' value="'+value['id']+'">'+ value['name'] +'</option>');
                })
              }
            }, 'json');
          }
        }
      }
      function detect_state(id){
        if(state_signup != id){
          state_signup = id;
          $('#city_signup').html('');
          $('#city_signup').html('<option value=""><?php echo $this->lang->line('label.city.select') ?></option>');
          if(id){
            $.post('<?php echo site_url('admin/ajax/list_json_city') ?>', {id : id}, function(data){
              if(data){                
                $.each(data, function(key, value){
                  $('#city_signup').append('<option '+
                    (value['id'] == '<?php echo isset($obj['city_id']) ? $obj['city_id'] : 0 ?>' ? 'selected="selected"' :'' )
                    +' value="'+value['id']+'">'+ value['name'] +'</option>');
                })
              }
            }, 'json');
          }
        }
      }
    </script>
  </head>
  <body>
    <div class="wrapper_screen">
      <div class="wrapper_main">
        <?php $this->load->view('user/_header') ?>
        <div class="contenu">
            <div class="lg_border2 w680" style="width: 762px;margin: 0px;float: left">
            <div class="form1">
              <form action="<?php echo site_url('signup/process') ?>" method="post" id="signup" enctype="multipart/form-data">
                <table class="table1">
                  <tr>
                    <td class="text4">Full name:<span class="require">*</span></td>
                    <td><input id="full_name" type="text" name="display_name" 
                               value="<?php echo empty($obj['display_name']) ? '' : $obj['display_name'] ?>" 
                               class="input1 validate[required]"/></td>
                  </tr>
                  <tr>
                    <td class="text4">Username:<span class="require">*</span></td>
                    <td><input id="username" type="text" name="username" 
                               value="<?php echo empty($obj['username']) ? '' : $obj['username'] ?>" 
                               class="input1 validate[required]"/></td>
                  </tr>
                  <tr>
                    <td class="text4">Password:<span class="require">*</span></td>
                    <td><input id="pass" type="password" name="password" value="" 
                               class="input1 validate[required]"/></td>
                  </tr>
                  <tr>
                    <td class="text4">Confirm password:<span class="require">*</span></td>
                    <td><input id="confirm_pass" type="password" name="confirm_pass" value="" 
                               class="input1 validate[required,equals[pass]]"/></td>
                  </tr>
                  <tr>
                    <td class="text4">Email:<span class="require">*</span></td>
                    <td><input id="edtLogin" type="text" name="email" 
                               value="<?php echo empty($obj['email']) ? '' : $obj['email'] ?>" class="input1 validate[required,custom[email]]"></td>
                  </tr>
                  <tr>
                    <td class="text4">Address:</td>
                    <td><input id="edtLogin" type="text" name="address" value="" class="input1"/></td>
                  </tr>
                  <tr>
                    <td class="text4">Select country:</td>
                    <td>
                      <select id="country_signup" name="country_id" class="input1">
                        <option selected="" value=""><?php echo $this->lang->line('label.country.select') ?></option>
                        <?php foreach ($countries as $country) { ?>
                          <option <?php echo isset($obj['country_id']) && $obj['country_id'] == $country['id'] ? 'selected="selected"' : '' ?>
                            value="<?php echo $country['id'] ?>"><?php echo $country['name'] ?></option>
                          <?php } ?>
                      </select>
                    </td>
                  </tr>
                  <tr>
                    <td class="text4">Select state:</td>
                    <td>
                      <select id="state_signup" name="state_id" class="input1">
                        <option selected="" value=""><?php echo $this->lang->line('label.state.select') ?></option>                        
                      </select>
                    </td>
                  </tr>
                  <tr>
                    <td class="text4">Select city:</td>
                    <td>
                      <select id="city_signup" name="city_id" class="input1">
                        <option selected="" value=""><?php echo $this->lang->line('label.city.select') ?></option>
                      </select>
                    </td>
                  </tr>
                  <tr>
                    <td class="text4">Avatar:</td>
                    <td><input class="" type="file" size="50" name="avatar" /></td>
                  </tr>
                  <tr>
                    <td class="text4">Captcha</td>
                    <td>
                      <input id="captcha" type="text" name="captcha" value="" placeholder="captcha" 
                             class="input1 validate[required]"/><br/><br/>
                             <?php echo $captcha['image'] ?>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="4">
                      <div class="more mg420" onclick="jQuery('#signup').submit();return false;">Sign up</div>
                    </td>
                  </tr>
                </table>
              </form>
            </div>
            <div class="clearer"></div> 
          </div>
          <?php echo $this->load->view('user/_right_index') ?>
        </div>
      </div>
    </div>
    <?php echo $this->load->view('user/_footer') ?>    
  </body>
</html>
